package net.myonlycdw.aspect;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.stereotype.Component;

import javax.xml.transform.Result;

/**
 * Created by Chen-D.W on 2017/6/10.
 */
@Component
@Aspect
public class Aop {

    @Pointcut(value = "execution(* net.myonlycdw.*.*.*(..))")//net.myonlycdw中所有文件夹的所
    public void PointCut(){}

//
//    @Before(value = "PointCut()")
//    public void doBefore(JoinPoint joinPoint){
//       String name= joinPoint.getSignature().getName();
//       Object[] obj=joinPoint.getArgs();
//        System.out.println(name+" " +obj.toString());
//
//    }
//
//
//    @After(value = "PointCut()")
//    public void doAfter(JoinPoint joinPoint){
//        System.out.println("切面成功了呀");
//    }
//
//
//    @AfterReturning(value = "PointCut()",returning = "result")
//    public void Afterreturning(JoinPoint joinPoint, Object result){
//        System.out.println(result);
//    }
    //重要的环绕切点
    @Around(value = "PointCut()")
    public void around(ProceedingJoinPoint proceedingJoinPoint){
        try {
            proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {
            throwable.printStackTrace();
        }
    }
}
